package com.tywj.lib.lifecycle.extension

import android.os.Looper
import androidx.lifecycle.MutableLiveData

/**
 * <pre>
 *     author : June Yang
 *     time   : 2020/05/19
 *     desc   : MutableLiveData扩展
 *     version: 1.0.0
 * </pre>
 */

/**
 * 更新数据，支持前台线程、后台线程
 * @param value
 */
fun <T> MutableLiveData<T>.post(value: T) {
    if (Looper.myLooper() == Looper.getMainLooper()) {
        setValue(value)
    } else {
        postValue(value)
    }
}
